<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS运算符</title>
</head>
<body>
<script>
    //如果比较运算符左右两边有数字,会转为数字再进行比较
    console.log(3>10);
    console.log('3'>10);
    console.log(3>'10');
    //如果比较运算符左右两边都是字符串,会比较它们的编码值
    console.log('3'>'10');//51>49=>true
    /* '3'.charCodeAt()查看字符的编码值 */
    console.log('3'.charCodeAt());//51
    console.log('10'.charCodeAt());//49
    //console.log('超'>'博');

    //除法会按照实际结果显示结果
    console.log(6/2);//3
    console.log(3/2);//1.5

    let a = 1;
    let b = true;
    //松散比较运算符,只比较值,Number(true)=1
    console.log(a == b);//true
    //严格比较运算符,先比较类型,再比较值 number ≠ boolean
    console.log(a === b);//false

    //Number() 将参数转为数字,如果得不到数字结果,就是NaN(Not a Number)
    //Boolean()
    //以下五个特殊值转为布尔都是false
    console.log(Boolean(false));
    console.log(Boolean(0));
    console.log(Boolean(''));
    console.log(Boolean(undefined));
    console.log(Boolean(null));

    //三元运算符 1
    let c = 0;
    console.log(c==0 ? 'YES' : 'NO');//'YES'
    //=是赋值符号,给c赋值为0,Boolean(0)=false,所以取3号位置的值'NO'
    console.log(c=0 ? 'YES' : 'NO');//'NO'


</script>
</body>
</html>